package widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.example.heimaplayer.R
import com.example.heimaplayer.model.HomeItemBean
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.item_home.view.*


class HomeItenView: RelativeLayout{
    fun setData(data: HomeItemBean) {
        tv_title.setText(data.title)
        tv_desc.setText(data.author)
        Picasso.get().load(data.album_500_500).into(img_bg)

    }

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )
//    接下来则需要对它进行布局的关联，这里可以在初始化方法中来写：
    init {
        View.inflate(context, R.layout.item_home,this)
    }
}